﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace jQueryExtensions.Samples.Models
{
    public class StockModel
    {
        
        public int? Id { get; set; }

        public string Code { get; set; }

        public float LastValue { get; set; }

        public IEnumerable<StockModel> FindByCode(string name)
        {
            var products = new List<StockModel>() 
            { 
                new StockModel() { Id = 1, Code = "JBSS3", LastValue=5.57F  } ,
                new StockModel() { Id = 2, Code = "BRFS3", LastValue=29.28F } ,
                new StockModel() { Id = 3, Code = "PETR4", LastValue=23F }, 
                new StockModel() { Id = 4, Code = "VALE3", LastValue=50.60F },
                new StockModel() { Id = 5, Code = "SANB11", LastValue=15.66F }
            };

            return products
                    .Where(x => x.Code.StartsWith(name));
        }

    }
}